package com.zzy.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;

import com.zzy.demo.dao.PersonDao;
import com.zzy.demo.model.Person;

@Service
public class PersonService {
	
	@Autowired
	PersonDao personDao;
	
    @Autowired
    private PasswordEncoder passwordEncoder;
	
	public  Person  addPerson(Person person){
		
		String password = person.getPassword();
		
		String encodePassword = passwordEncoder.encode(password);
		
		person.setPassword(encodePassword);
		
		Person dbPerson = personDao.save(person);
		return dbPerson;
	}

}
